k8s取得登入憑證

睡睡念

幫同事新建一組drone 自動部署的新專案,
要發版到自建的k8s上面,
終於碰到我不想面對的東西了。
kube_ca ,kube_token ,我哪知道這兩個東西在哪裏阿

正文

Drone Kubernetes可以知道,一個是使用者,一個是ca認證的key,
但我還不知道去哪生這兩個東西出來。

KUBE_TOKEN This plugin has one authentication method and that is to use the token to authorize the user.

KUBE_CA This should be the base64 encoding of your certificate authority. You can get this string by running the command:

跑去問了一下chatGPT,得到答案。
執行指令前,必須先連到你要取得的cluster上。

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep cluster-admin | awk '{print $1}')

我的列出有很多個,就拿第一個看起來也最像的來用了。
admin-user-token-tm7g4
143-fig.1.jpg
這邊就會看到token。

再來是ca

kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}'

143-fig.2.jpg

放到drone上面,驗證,收工。

143-fig.3.jpg

ref. 使用者認證